package com.example.goodsass.controller;

import com.example.goodsass.domain.ArticleCategories;
import com.example.goodsass.service.ArticleCategoriesService;
import com.example.goodsass.vo.goodsVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("article_categories")
@Tag(name = "article_categories",description = "文章分类")
public class ArticleCategoriesController {
    @Autowired
    ArticleCategoriesService articleCategoriesService;
    @Operation(description = "selByPage")
    @GetMapping("selByPage")
//    分页查询
    public List<ArticleCategories> selByPage(Integer pageNo,Integer pageSize) {
        return articleCategoriesService.selByPage(pageNo,pageSize);
    }

    @Operation(description = "新增")
    @PostMapping("/add")
    public String add(@RequestBody ArticleCategories articleCategories){
        articleCategoriesService.save(articleCategories);
        return "新增成功";
    }

    @Operation(description = "selByIdOrName")
    @GetMapping("selByIdOrName")
//    ID/Name查询
    public ArticleCategories selByIdOrName(String id, String name) {
        return articleCategoriesService.selByIdOrName(id,name);
    }
    @Operation(description = "updById")
    @PostMapping("updById")
//    Id更新
    public String updById(@RequestBody ArticleCategories articleCategories) {
        return articleCategoriesService.updById(articleCategories);
    }
    @Operation(description = "delById")
    @GetMapping("delById")
//    Id删除
    public String delById(String id) {
        return articleCategoriesService.delById(id);
    }
}
